% Stephen Molloy, ESS
%
\documentclass[12pt]{essreqs}
\usepackage{amsfonts,amsmath,color,lscape,multirow} 
\usepackage[colorlinks=true,linkcolor=blue,pagecolor=red,citecolor=blue,urlcolor=blue,breaklinks=true,hyperfootnotes=false,pdftitle={ESS requirements documentation},pdfauthor={author},pdfkeywords={tag1,tag2,tag3}]{hyperref}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{tabulary}
\usepackage{longtable}
\usepackage{colortbl}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage[a4paper,vmargin={20mm,20mm},hmargin={10mm,10mm}]{geometry}
\usepackage{fancyhdr}
\usepackage{floatrow}
%\floatsetup{style=Plaintop}
%\usepackage{draftwatermark}
%\SetWatermarkAngle{45.0}
%\SetWatermarkFontSize{48pt}
%\SetWatermarkScale{6}
%\SetWatermarkLightness{0.95}

\usepackage[english]{babel}
\usepackage{datatool}

%\usepackage[cm-default]{fontspec}
%\usepackage{xunicode}


\renewcommand*{\rmdefault}{cmss}

%\setcounter{secnumdepth}{3} % subsubsections with numbers
\setcounter{tocdepth}{3} % include subsubsections in toc

\setlength{\headheight}{80pt}

\newcommand{\Title}{Document title}
\newcommand{\Author}{Name Surname}

\title{\Title}
\author{\Author}
\date{\today}
\DTLloaddb{reqs}{requirements.csv}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[C]{
  \begin{tabularx}{\textwidth}{|c|X|X|c|}
  \hline
  \multirow{4}{*}{\includegraphics[width=0.2\textwidth]{figs/ess-logo.pdf}} & \multicolumn{2}{|>{\centering}X|}{ } & \multirow{4}{*}{\includegraphics[width=0.2\textwidth]{figs/ess-logo.pdf}} \\
   & \multicolumn{2}{|>{\centering}X|}{\Large Requirements:} & \\
   & \multicolumn{2}{|>{\centering}X|}{\Large \Title} & \\
   & \multicolumn{2}{|>{\centering}X|}{ } & \\
  \hline
  {\footnotesize \textbf{Author:} \Author} & \multicolumn{2}{|>{\centering}X|}{{\footnotesize \textbf{Date:} \today}} & \\
  \hline
  \end{tabularx}
  }

\begin{document}
\thispagestyle{plain}
\maketitle

\begin{center}
\begin{tabulary}{0.85\textwidth}{!{\vrule width 2pt}C!{\vrule width 2pt}}
\noalign{\hrule height 2pt}
\rowcolor{BlueGreen}\\

\rowcolor{BlueGreen}\multirow{-2}{*}{\Huge Summary} \\
\noalign{\hrule height 2pt}
\begingroup
\obeylines
\input{requirements-summary.txt}%
\endgroup%
\\
\noalign{\hrule height 2pt}
\end{tabulary}
\end{center}

\newpage

\begin{longtable}{|m{0.03\textwidth}|>{\raggedright}m{0.13\textwidth}|m{0.62\textwidth}|m{0.12\textwidth}|}
\hline
\noalign\bgroup
\DTLforeach{reqs}{
\1=Num, \2=Title, \3=Text, \4=Date}{\egroup\ifthenelse{\value{DTLrowi}>0}{
{\small \1} & {\small \textbf{\2}} & {\small \3} & {\small \4} \\[8ex] \hline }{}\noalign\bgroup}\egroup
\end{longtable}

\end{document}